#ifndef __EASYFIFO_H__
#define __EASYFIFO_H__
#include "stdlib.h"
#include "stdint.h"
#include "stdbool.h"

typedef struct
{
	char *name;
	uint8_t *base;
	size_t max_size;
	bool lock_enable;
	void (*lock)(void);
	void (*unlock)(void);
}efifo_init_struct_t;

typedef struct
{
	efifo_init_struct_t init_struct;
	
	uint32_t wr_idx;
	uint32_t used;
	int int_context;
}easy_fifo_t;

int efifo_init(easy_fifo_t *fifo);
size_t efifo_get_used(easy_fifo_t *fifo);
size_t efifo_get_free(easy_fifo_t *fifo);
bool efifo_write(easy_fifo_t *fifo,uint8_t *src,size_t count);
bool efifo_write_roll(easy_fifo_t *fifo,uint8_t *src,uint32_t count);
size_t efifo_read(easy_fifo_t *fifo,uint8_t *r_buffer,size_t count);
size_t efifo_pick(easy_fifo_t *fifo,uint8_t *r_buffer,size_t count);
void efifo_clean(easy_fifo_t *fifo);
size_t efifo_cut(easy_fifo_t *fifo,size_t count);


void efifo_unlock_by_en_int(void);
void efifo_lock_by_dis_int(void);
#endif














